package model;

import java.util.GregorianCalendar;

public abstract class Prescription {
	private GregorianCalendar startDate;
	private GregorianCalendar endDate;
	private Drug drug = null;

	public Prescription(GregorianCalendar startDate, GregorianCalendar endDate) {
		this.startDate = startDate;
		this.endDate = endDate;
	}
	
	public GregorianCalendar getStartDate() {
		return startDate;
	}

	public GregorianCalendar getEndDate() {
		return endDate;
	}

	/**
	 * Returns the count of days between start date and end date (both
	 * inclusive).
	 */
	public long dayCount() {
		return (endDate.getTimeInMillis() - startDate.getTimeInMillis())
				/ (24 * 60 * 60 * 1000) + 1;
	}

	public void setDrug(Drug drug) {
		this.drug = drug;
	}

	public Drug getDrug() {
		return drug;
	}
	
	public void removeDrug() {
		drug = null;
	}
	
	public String toString() {
		return startDate.get(GregorianCalendar.DATE) + "."
				+ (startDate.get(GregorianCalendar.MONTH) + 1) + "."
				+ startDate.get(GregorianCalendar.YEAR);
	}

	public abstract double totalDose();

	public abstract double dayDose();

}
